#include <VisitorrEmoveItemFromNode.h>
#include <SceneViewer.h>
#include <NodeInformationContainer.h>
#include <SceneViewerFunctions.h>
//#include <ObjectListGenerate.h>
#include <OsgClassDataSource/ObjectOsg.h>
#include <NodeInfoContainer.h>
#include <ClassFactoryObjectOsg.h>
#include <ClassFactoryObjectOsg.h>

VisitorrEmoveItemFromNode::VisitorrEmoveItemFromNode()
{
	setTraversalMode(osg::NodeVisitor::TraversalMode::TRAVERSE_ALL_CHILDREN);
	setTraversalMask(0xffffffff);
    setNodeMaskOverride(0xffffffff);
}

VisitorrEmoveItemFromNode::~VisitorrEmoveItemFromNode()
{

}

void VisitorrEmoveItemFromNode::apply( osg::Node& node )
{
    /*
    NodeInfoContainer* infoContainer = dynamic_cast<NodeInfoContainer*>(node.getUserDataContainer());
    if(infoContainer == NULL)
    {
        ObjectOsg* objOsgPtr = creatObjOsg(&node);
        if(objOsgPtr != NULL)
        {
            m_previousItemList.at(m_previousItemList.size() -1 )->appendRow(objOsgPtr->getObjItem());

            NodeInfoContainer* newInfoContainer = new NodeInfoContainer;
            newInfoContainer->setObjectInspectorItem( objOsgPtr->getObjItem() );
            node.setUserDataContainer(newInfoContainer);
            m_currentItem = objOsgPtr->getObjItem();
        }
    }
    else
    {
        m_currentItem = infoContainer->getObjectInspectorItem();
    }
    //QStandardItem* previousItem = m_currentItem;

    if(m_currentItem != NULL)
    std::cout<<"currentItemText ="<<m_currentItem->text().toStdString()<<std::endl;

    m_previousItemList.push_back(m_currentItem);
    traverse(node);
    m_previousItemList.pop_back();

*/
    //NodeInfoContainer* infoContainer = dynamic_cast<NodeInfoContainer*>(node.getUserDataContainer());
    (&node)->setUserDataContainer(NULL);
    traverse(node);
}

